package pers.liyan.shi.springboot.config;

import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 缓存配置
 */
@Configuration
public class MyCacheConfig {

    /**
     * 自定义缓存的 KeyGenerator
     * @return
     */
    @Bean("myKeyGenerator")
    public KeyGenerator keyGenerator(){
        return (Object target, Method method, Object... params) -> {
            return method.getName() + Arrays.asList(params);
        };
    }

}
